#ifndef FPLAYER_FFMPEGRENDER_H
#define FPLAYER_FFMPEGRENDER_H

#include "Render.h"
#include "Codec.h"
#include "ResampleWrapper.h"

/**
 * author: x-fan
 * date: 2024/1/15
 * desc: FFMpeg复用
 */
class FFMpegRender : public IRender, public IEncodeCallback{
private:
  //复用格式上下文
  AVFormatContext *_pFormatCtx = nullptr;
  //复用的字典
  AVDictionary *_pOptions = nullptr;
  //视频流
  AVStream *_pVStream = nullptr;
  //音频流
  AVStream *_pAStream = nullptr;

protected:
  /**
   * 获取输出格式类型
   * @return 输出格式类型
   */
  virtual const char *getFormatName() = 0;

public:
  explicit FFMpegRender(RenderParam *pRenderParam);

  virtual ~FFMpegRender() noexcept;

  void startRender() override;

  void stopRender() override;

  void resumeRender() override;

  void pauseRender() override;

  int32_t capacity() override;

  void onEncodeData(IEncoder *pEncoder, AVPacket *pPacket) override;
};

#endif //FPLAYER_FFMPEGRENDER_H
